﻿/* Copyright 2008 dnAnalytics Project.
 *
 * Contributors to this file:
 * Marcus Cuda
 *
 * This file is part of dnAnalytics.  dnAnalytics is licensed under the 
 * Microsoft Public License. See License.txt for a complete copy of the
 * license.
 */

using System;

namespace dnAnalytics.LinearAlgebra
{
    public partial class HouseholderTransformation
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="HouseholderTransformation"/> class.
        /// </summary>
        /// <param name="vector">The vector.</param>
        public HouseholderTransformation(Vector vector)
        {
            if (vector == null)
            {
                throw new ArgumentNullException("vector");
            }
            mVector = new DenseVector(vector);
            Compute();
        }

        //using LAPACK DLARGF
        private void Compute()
        {
            SafeNativeMethods.d_householder(mVector.Count + 1, ((DenseVector)mVector).Data);
            mBeta = mVector[0];
            mVector[0] = 1;
        }
    }
}
